package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BasicKeyRegionVo;
import com.macro.mall.dto.e.SysAreaEntDTO;
import com.macro.mall.query.RegionQuery;
import com.macro.mall.service.SysAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/area")
public class SysAreaController {

    @Autowired
    private SysAreaService sysAreaService;

    @RequestMapping("/list")
    public CommonResult list(@RequestBody RegionQuery query) {
        return sysAreaService.list(query);
    }

    @RequestMapping("/get")
    public CommonResult get(@RequestBody SysAreaEntDTO sysAreaEntDTO) {
        return null;
    }

    @RequestMapping("/modify")
    public CommonResult modify(@RequestBody BasicKeyRegionVo region) {
        return sysAreaService.modify(region);
    }

    @RequestMapping("/setStatus")
    public CommonResult setOn(@RequestBody BasicKeyRegionVo region) {
        return sysAreaService.modify(region);
    }

    @RequestMapping("/setOff")
    public CommonResult setOff(@RequestBody SysAreaEntDTO sysAreaEntDTO) {
        return null;
    }

    /***
     * 添加 地区
     * @param region
     * @return
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody BasicKeyRegionVo region) {
        return sysAreaService.add(region);
    }


    /***
     * 删除 地区
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public CommonResult delete(@PathVariable Long id) {
        return sysAreaService.delete(id);
    }


}
